#include <iostream>
#include <leveldb/db.h>

using namespace std;

int main(int argc, char *argv[])
{
    leveldb::DB     *db;
    leveldb::Options options;
    options.create_if_missing = true;
    leveldb::Status status    = leveldb::DB::Open(options, "/tmp/testdb", &db);
    if (!status.ok()) {
        std::cout << "open db failed" << std::endl;
        return -1;
    }

    db->Put(leveldb::WriteOptions(), "key1", "value1");
    db->Put(leveldb::WriteOptions(), "key2", "value2");
    db->Put(leveldb::WriteOptions(), "key3", "value3");

    std::string value;
    db->Get(leveldb::ReadOptions(), "key1", &value);
    std::cout << "key1: " << value << std::endl;
    db->Get(leveldb::ReadOptions(), "key2", &value);
    std::cout << "key2: " << value << std::endl;
    db->Get(leveldb::ReadOptions(), "key3", &value);
    std::cout << "key3: " << value << std::endl;

    db->Delete(leveldb::WriteOptions(), "key1");

    delete db;
    leveldb::DestroyDB("/tmp/testdb", options);
    return 0;
}